package org.bugjail.servlet.form.edit;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.bugjail.data.Person;
import org.bugjail.servlet.BasicUIServlet;

/**
 * Servlet implementation class for Servlet: NewSuiteFormServlet
 * 
 */
public class EditCurrentUserFormServlet extends BasicUIServlet {

	static final long serialVersionUID = 1L;

	@Override
	protected void write(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		Person user = getLoggedUser();

		PrintWriter pw = response.getWriter();

		pw.println("<form method='post' action='EditCurrentUserServlet'>");
		pw.println("Name:<br><input type='text' name='name' maxlength='50' value='"+user.getName()+"' /><br>");
		pw.println("Mail:<br><input type='text' name='mail' maxlength='50' value='"+user.getMail()+"' /><br>");
		
		pw.println("Change password: <br><input type='password' name='pass' maxlength='50' value='' /><br>");
		pw.println("Confirm password:<br><input type='password' name='passconfirm' maxlength='50' value='' /><br>");
		
		pw.println("<input type=hidden name='userid' value='" + user.getId() + "' />");
		pw.println("<input type=submit value='Update' />");
		pw.println("&nbsp;<a href='HomeServlet'>Cancel</a>");
		pw.println("</form>");
	}

	@Override
	protected String pageTitle() {
		return "Edit current user";
	}

	@Override
	protected void beforeAction(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

	}
}